// 行政区数据处理函数
export const formatAreaData = (data, level = 3, disabledOptions = []) => {
	if (!data) return;
	return data.map(item => {
		let defaultData = {
			code: Number(item.value),
			name: item.title,
			disabled: disabledOptions.includes(Number(item.value))
		};
		switch (level) {
			case 1:
				return defaultData;
			case 2:
				return {
					...defaultData,
					children:
						item.children &&
						item.children.map(val => {
							const childData = {
								code: Number(val.value),
								name: val.title,
								disabled: disabledOptions.includes(Number(val.value))
							};
							if (
								childData.name === '市辖区' ||
								childData.name === '县' ||
								childData.name === '主城区'
							) {
								childData.name = defaultData.name + '-' + childData.name;
							}
							return childData;
						})
				};
			case 3:
				return {
					...defaultData,
					children: formatAreaData(item.children, 2, disabledOptions)
				};
		}
	});
};
